package com.en.effectiveJava.chapter2.singleton3;

import java.io.Serializable;

/**
 * 私有构造器, 公有的静态 final 域实现 Singleton
 * Create by EN
 * On 24/05/18 4:27 PM
*/
public class PrivateConstructor implements Serializable {

    public static final PrivateConstructor INSTANCE = new PrivateConstructor();

    private PrivateConstructor() {
        //防止该类被第二次创建
        if (INSTANCE != null) {
            throw new RuntimeException("Can't create this bean again!");
        }
    }

    public void say() {
        System.out.printf("I'm PrivateConstructor, I'm built!\n");
    }

}
